<!-- 
	Transaction payees table 
	
	@author mrduongnv@gmail.com  
-->

<%@include file="/WEB-INF/taglibs/common/taglibs.jsp"%>

<table width="100%">
	<tr>
		<td><table width="100%">
			<tbody id="payeeTable${transactionIndex}">
				<c:forEach var="trAmount" items="${newTransaction.transactionAmounts}" varStatus="payeeIndex">
					<tr class="payeeAmountRow">
						<td><spring:message code="sp.transactionpayess.label.payee" /></td>				
						<td width="70%">
							<div style="border: 1px none #ff0000; width: 80%" >
								<form:select cssStyle="width: 100%;" cssClass="payeeSelector" 
									path="transactionDetails[${transactionIndex}].transactionAmounts[${payeeIndex.index}].selectedPayeeId"
									disabled="${newTransaction.approved or newTransactionForm.approved}" >
									<form:option value="0" label="Select payee" />
									<form:options items="${trAmount.payees}" itemValue="id" itemLabel="fullName" />
								</form:select>
							</div>
						</td>
						<td><spring:message code="sp.transactionpayess.label.amount" /></td>
						<td width="30%">
							<form:input cssStyle="width: 80%;" cssClass="payeeAmount" 
								path="transactionDetails[${transactionIndex}].transactionAmounts[${payeeIndex.index}].amount" 
								disabled="${newTransaction.approved or newTransactionForm.approved}"/>
						</td>
						<c:choose>
							<c:when test="${newTransaction.approved or newTransactionForm.approved}">
								<td><input type="button" class='ui-button ui-state-default ui-corner-all' name="deletePayeeBtn" value="<spring:message code="sp.transactionpayess.button.delete" />" disabled="disabled" />
								</td>
							</c:when>
							<c:otherwise>
								<td><input type="button" class='ui-button ui-state-default ui-corner-all' name="deletePayeeBtn" value="<spring:message code="sp.transactionpayess.button.deletepayee" />" 
									onclick="deletePayee(${transactionIndex}, ${payeeIndex.index}); return false;" />
								</td>							
							</c:otherwise>
						</c:choose>							
					</tr>
				</c:forEach>
			</tbody>
		</table></td>
	</tr>
	<tr>
		<td>
			<c:choose>
				<c:when test="${newTransaction.approved or newTransactionForm.approved}">
					<input type="button" class='ui-button ui-state-default ui-corner-all' name="addPayeeBtn" value="<spring:message code="sp.transactionpayess.button.addpayee" />" disabled="disabled" />
				</c:when>
				<c:otherwise>
					<input type="button" class='ui-button ui-state-default ui-corner-all' name="addPayeeBtn" value="<spring:message code="sp.transactionpayess.button.addpayee" />" onclick="addPayee(${transactionIndex}); return false;" />
				</c:otherwise>
			</c:choose>
		</td>
	</tr>
</table>
